<?php
// 引入数据库连接文件
if (!isset($con)) {
    die("Database connection variable is not set.");
}
?>
<div id="middle">
    <div id="left">
        <div id="up">
            <div class="news-title">热点新闻</div>
            <div id="news">
                <ul>
                    <?php
                    $newssql = "select * from news order by id desc limit 0,5";
                    $newsquery = mysqli_query($con, $newssql);
                    // 移除多余的 mysqli_fetch_array 调用
                    while ($newsrow = mysqli_fetch_array($newsquery, MYSQLI_ASSOC)) {
                    ?>
                        <li class="news"><a href="newslist.php?newsid=<?php echo $newsrow['id']; ?>"><?php echo substr($newsrow['title'], 0, 80); ?></a></li>
                    <?php
                    }
                    ?>
                </ul>
                <div class="more-link"><a href="newslist.php">更多新闻 >></a></div>
            </div>
        </div>
        <div id="down">
            <div class="news-title">个人信息</div>
            <ul class="profile-list">
                <?php
                $sql = "select * from qiye";
                $query = mysqli_query($con, $sql);
                $row = mysqli_fetch_array($query, MYSQLI_ASSOC);
                ?>
                <ul style="list-style-type: none; padding: 0;">
                    <li style="margin:2px;">电话：<?php echo $row['tel'] ?></li>
                    <li style="margin:2px;">传真：<?php echo $row['chuanzhen'] ?></li>
                    <li style="margin:2px;">邮箱：<?php echo $row['email'] ?></li>
                    <li style="margin:2px;">业务部负责人：<?php echo $row['yewuname'] ?></li>
                    <li style="margin:2px;">技术部负责人：<?php echo $row['jishuname'] ?></li>
                    <li style="margin:2px;">技术咨询电话：<?php echo $row['jishutel'] ?></li>
                </ul>
                <img src="images/wx1.png" class="wechat-qr" />
        </div>
    </div>
    <div id="right">
        <div id=geren>
            <div class="news-title">个人简介</div>
            <p style="padding-left: 15px;width: 96%;">
                我是张宝帆——<br>
                昼伏夜出的代码吟游诗人，<br>
                用 Python 谱写十四行诗，<br>
                用 JavaScript 绘制星空图，<br>
                在 Git 的时空中，追寻版本进化的永恒之美。</p>
        </div>

        <div class="pro">
            <div class="news-title">产品推荐</div>
            <div class="pro-grid">
                <?php
                $prosql = "select * from pro order by id desc limit 0,3";
                $proquery = mysqli_query($con, $prosql);
                while ($prorow = mysqli_fetch_array($proquery, MYSQLI_ASSOC)) {
                    echo "<div class='pro-item'>
                            <div class='pro-image'>
                                <a href='proshow.php?proid=" . $prorow['id'] . "'>
                                    <img src='admin/uploadimg/" . $prorow['propic'] . "' alt='" . $prorow['proname'] . "' />
                                </a>
                            </div>
                            <div class='pro-title'>
                                <a href='proshow.php?proid=" . $prorow['id'] . "' title='" . $prorow['proname'] . "'>" . 
                                    substr($prorow['proname'], 0, 18) . 
                                "</a>
                            </div>
                          </div>";
                }
                ?>
                <div class='pro-item'>
                    <a href='proshow.php' style='display: flex; justify-content: center; align-items: center; height: 100%; text-decoration: none; color: #2c662d;'>
                        <span style='font-size: 16px;'>更多产品 >></span>
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>